package com.smc.demo.common;

/**
 * Created by stx on 2020/9/6.
 * 单列模板
 */

public abstract class Singleton<T> {
    private T instance;

    public final T get(){
        if (instance == null){
            synchronized (this){
                if (instance == null){
                    instance = create();
                }
            }
        }
        return instance;
    }

    public abstract T create();
}
